package com.solcoo.controller;

import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.solcoo.pojo.Menu;
import com.solcoo.service.MenuService;

@Controller
public class MenuController {
	@Resource
	private MenuService menuService;
	
	@RequestMapping(value="addMenu.do")
	public @ResponseBody Map<String, Object> addMenu(Menu menu, Integer screenWidth, 
			@RequestParam(required = false) MultipartFile menuPic, HttpServletRequest request) throws Exception {
		return menuService.addMenu(menu, screenWidth, menuPic, request);
	}
	
	@RequestMapping(value="deleteMenu.do")
	public @ResponseBody Map<String, Object> deleteMenu(Long id) throws Exception {
		return menuService.deleteMenu(id);
	}
	
	@RequestMapping(value="updateMenu.do")
	public @ResponseBody Map<String, Object> updateMenu(Menu menu) throws Exception {
		return menuService.updateMenu(menu);
	}
	
	@RequestMapping(value="updateMenuPic.do")
	public @ResponseBody Map<String, Object> updateMenuPic(Long id, 
			@RequestParam(required = false) MultipartFile menuPic) throws Exception {
		return menuService.updateMenuPic(id, menuPic);
	}
	
	@RequestMapping(value="getMenu.do")
	public @ResponseBody Map<String, Object> getMenu(Long id) throws Exception {
		return menuService.getMenu(id);
	}
	
    @RequestMapping(value="listMenu.do")
    public @ResponseBody Map<String, Object> listMenu(Long shanghuid, String menuType, 
    		String sortType, Integer screenWidth, String isShanghu) throws Exception {
    	return menuService.listMenu(shanghuid, menuType, sortType, screenWidth, isShanghu);
    }
	
}